<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:f="http://java.sun.com/jsf/core">

    <!--
    
    Copyright 2007-2012 Audrius Valunas

    This file is part of OpenACS.

    OpenACS is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    OpenACS is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with OpenACS.  If not, see <http://www.gnu.org/licenses/>.

    -->

    <ui:composition template="mt.xhtml">
        <a4j:loadStyle src="css/svclist.css" />
        <ui:define name="title">Services for #{Cpe.sn}</ui:define>
        <ui:define name="body">
            <h4>Services assigned to #{Cpe.sn}</h4>
            <h:form id="services">
                <rich:dataTable id="svclist" value="#{Cpe.services}" var="svc">
                    <rich:column colspan="2">
                        <h:panelGrid columns="2">
                            <h:commandLink
                                style="display:block;height:20px;border-bottom:0px;border-top:0px"
                                action="#{Cpe.ServiceUnassign}"
                                reRender="svclist" onclick="if (!confirm('Are you sure you want to remove it?')) { return false; }">
                                <h:graphicImage
                                    style="border-bottom:0px;border-top:0px;border-left:0px;border-right:0px"
                                    value="/images/remove_icon.gif"
                                    width="15" height="15" longdesc="Remove" />
                                <a4j:actionparam name="svcid" value="#{svc.id}" assignTo="#{Cpe.svcidin}"/>
                                <a4j:actionparam name="svcinstance" value="#{svc.instance}" assignTo="#{Cpe.svcinstancein}"/>
                            </h:commandLink>
                            <h:outputText value="#{svc.name} (#{svc.instance})" />
                        </h:panelGrid>
                        <rich:subTable id="vars" value="#{svc.properties}" var="v">
                            <rich:column>
                                <h:outputText value="#{v.name}" />
                            </rich:column>
                            <rich:column>
                                <rich:inplaceInput  value="#{v.value}" defaultLabel="click to enter value"
                                                    showControls="true" id="valueInplaceInput"
                                                    controlsHorizontalPosition="left" controlsVerticalPosition="bottom">
                                </rich:inplaceInput>
                            </rich:column>
                        </rich:subTable>
                    </rich:column>
                </rich:dataTable>
                <br />
                <h:selectOneMenu value="#{Cpe.svcidin}">
                    <f:selectItems   value="#{Service.list}" />
                </h:selectOneMenu>
                <rich:spacer height="1"  width="10" />
                <h:commandButton type="submit" value="Assign" action="#{Cpe.ServiceAssign}" reRender="svclist"/>
                <br />

                <h:commandButton type="submit" value="Save" action="#{Cpe.Save}"/>
            </h:form>
        </ui:define>
        <ui:define name="lmenu"><ui:include src="cpe_menu.xhtml" /> </ui:define>
    </ui:composition>
</html>